﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="goodsSpecifications.aspx.cs" Inherits="WebApp.admin.goods.goodsSpecifications" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
	添加规格
</title><link href="../css/skin.css" rel="stylesheet" type="text/css" /></head>
<script type="text/javascript" src="../js/main.js">    var i = 0;</script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.1.js"></script>
<script type="text/javascript" src="../js/uploadPreview.js"></script>

<script type="text/javascript">
    ///添加表单选项
    function AddSpecificationsValue() {
        var tb = document.getElementById("SpecificationsValues");
        var length = tb.rows.length;
        newRow = tb.insertRow(length);
        newRow.width = "100%";
        newCell0 = newRow.insertCell(0);
        newCell0.innerHTML = "<input name=\"specificationsValue\" type=\"text\"/>";
        newCell1 = newRow.insertCell(1);
        newCell1.innerHTML = "<div class=\"specificationValueImagePreview\" id=\"imgDiv" + length + "\"></div> "
        +"<input name=\"specImages\" type=\"hidden\" value=\"4\" />"
        +"<input class=\"specificationValueImageUploadButton\" id=\"imgfile" + length + "\" name=\"fileSVimage\" type=\"file\"  onchange=\"fileupload('#imgfile" + length + "','#imgDiv" + length + "');\"/><span class=\"imgClass\">图片大小：30*30 分辨率：72像素 格式：jpg,bmp,gif,png</sapn>";
        newCell2 = newRow.insertCell(2);
        newCell2.innerHTML = "<input type=button class=\"formButton\" value=\"删除\" title=\"删除规格值\" onclick=\"delSVInput(this.parentNode.parentNode.rowIndex);\">";
        displaySpecificationsValueImage();
    }
    ///删除规格值表单选项
    function delSVInput(index) {
        if (confirm("确定要删除吗？")) {
            var tb = document.getElementById("SpecificationsValues");
            document.getElementById("SpecificationsValues").deleteRow(index);
        }
    }
    ///显示隐藏规格图片
    function displaySpecificationsValueImage() {
        var sft = document.getElementsByName("specificationsType");
        var tbSV = document.getElementById("SpecificationsValues");
        if (sft[0].checked)
            for (var i = 0; i < tbSV.rows.length; i++) {
                tbSV.rows[i].cells[1].style.display = "none";
            }
        else if (sft[1].checked)
            for (var i = 0; i < tbSV.rows.length; i++) {
                tbSV.rows[i].cells[1].style.display = "block";
            }
    }
    ///上传图片预览
    function fileupload(fileId, imgId) {
        $(fileId).uploadPreview({ width: 30, height: 30, imgDiv: imgId, imgType: ["bmp", "gif", "png", "jpg"], maxwidth: 100, maxheight: 100 });
    }
    function checkSpecificationsForm() {
        var specificationsName = document.getElementById("txtSpecificationsName");
        if (specificationsName.value == "") {
            alert("请输入规格名称！");
            specificationsName.focus();
            return false;
        }
        var specificationsValue = document.getElementsByName("specificationsValue");
        if (specificationsValue.length == 0) {
            alert("请添加规格值！");
            return false;
        }
        for (var i = 0; i < specificationsValue.length; i++) {
            if (specificationsValue[i].value == "") {
                alert("请输入规格值名称！");
                specificationsValue[i].focus();
                return false;
            }
        }
        var specificationsType = document.getElementsByName("specificationsType");
        if (specificationsType[1].checked) {
            var fileSVimage = document.getElementsByName("fileSVimage");
            var imageShow = document.getElementsByName("imageShows");
            for (var i = 0; i < fileSVimage.length; i++) {
                if (fileSVimage[i].value == "" && imageShow[i].src == "") {
                    alert("请选择规格图片！");
                    specificationsValue[i].focus();
                    return false;
                }
                else {
                    //检测类型
                    var val = fileSVimage[i].value.toLowerCase();
                    if (val != "") {
                        if (/^.*?\.(gif|png|jpg|jpeg|bmp)$/.test(val)) {
                        } else {
                            alert("规格图片只能上传gif, png, jpg, bmp格式的图片");
                            fileSVimage[i].select();
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }

</script>

<body class="body">
    <table class="main" cellpadding="0" cellspacing="0">

        <tr>
            <td class="td_middle_middle">
                <div class="maincontent">

                <div  class="navgater"><img src="../images/module.gif" width="20" height="22" alt=""/>
所在位置：销售规格->
<%= Request.QueryString["ot"] == "ed" ? "规格编辑" : "规格添加"%>

<a style=" display:block; float:right;" href="javascript:location.href=document.referrer;" ><img src="../images/history.gif" border="0" /></a>
</div>
                    <form name="form1" runat="server">

                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td class="td_title">
                                    规格名称：</td>
                                <td class="td_content">
                                    <input name="txtSpecificationsName" runat="server" type="text" id="txtSpecificationsName" />*</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    规格类型：</td>
                                <td class="td_content">
                                    <input value="0" name="specificationsType" runat="server" type="radio" id="rdSpecificationsType" onclick="displaySpecificationsValueImage();" checked="true" />文字类型&nbsp;&nbsp;
                                    <input value="1" name="specificationsType" type="radio" id="rdSpecificationsType1" runat="server" onclick="displaySpecificationsValueImage();" />图片类型
                                </td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    显示方式：</td>
                                <td class="td_content">
                                    <input value="0" name="showType" type="radio" runat="server" id="rdShowType" checked="true" />平铺方式&nbsp;&nbsp;
                                    <input value="1" name="showType" type="radio" runat="server" id="rdShowType1" />下拉方式</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    备注：</td>
                                <td class="td_content">
                                    <input name="txtRemark" type="text"  runat="server" id="txtRemark" />*</td>
                            </tr>
                            <tr>
                                <td class="td_title">
                                    规格值：</td>
                                <td class="td_content">
                                    <input id="addSV" type="button" class="formButton" value="添加规格值" title="添加规格值" onclick="AddSpecificationsValue();" />
                                    <table border="0" cellspacing="0" id="SpecificationsValues" runat="server">
                                        <tr>
                                            <td>
                                                规格值名称</td>
                                            <td style='display: <%= PicShow %>;'>
                                                规格图片</td>
                                            <td>
                                                操作</td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                      <asp:Button ID="bntSubmit" runat="server" Text="确  定" CssClass="formButton" OnClick="btnSubmit_Click"
                                        OnClientClick="return checkSpecificationsForm();" />&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input id="btnBack" type="button" class="formButton" value=" 返  回 " onclick="javascript:location.href=document.referrer;" />
                                    </td>
                               
                            </tr>
                        </table>

                        </form>
                   </div>
            </td>

        </tr>
      
    </table>
</body>
</html>
